package bma.common.langutil.cron;

public class CrontabServiceBean {

	private CrontabService service;
	private String name;
	private String cron;
	private Runnable runnable;
	private CrontabTask task;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public CrontabService getService() {
		return service;
	}

	public void setService(CrontabService service) {
		this.service = service;
	}

	public String getCron() {
		return cron;
	}

	public void setCron(String cron) {
		this.cron = cron;
	}

	public Runnable getRunnable() {
		return runnable;
	}

	public void setRunnable(Runnable runnable) {
		this.runnable = runnable;
	}

	public void start() {
		if (task == null) {
			task = service.createTask(name, cron, runnable);
			task.start();
		}
	}

	public void stop() {
		if (task != null) {
			task.stop();
		}
	}
}
